package com.yaofeng.mybatis.config;

import com.yaofeng.mybatis.interceptor.RefreshTokenInterceptor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * 拦截器配置
 * Created by yaofeng on 2019/9/5.
 */

@Configuration
public class WebAppConfigurer implements WebMvcConfigurer {

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        //刷新token拦截的管理器
        InterceptorRegistration registration = registry.addInterceptor(new RefreshTokenInterceptor());     //拦截的对象会进入这个类中进行判断
        registration.addPathPatterns("/**");                    //所有路径都被拦截
        registration.excludePathPatterns("/","/sys/auth/login","/error","/static/**","/sys/auth/logout");  //添加不拦截路径
    }
}
